using Microsoft.AspNetCore.Mvc;
using ZR.Model.ProdManage.Dto;
using ZR.Model.ProdManage;
using ZR.Service.ProdManage.IProdManageService;
using ZR.Admin.WebApi.Filters;

//创建时间：2025-05-18
namespace ZR.Admin.WebApi.Controllers.ProdManage
{
    /// <summary>
    /// 三级装箱明细
    /// </summary>
    [Verify]
    [Route("ProdManage/ProdThreePackDetail")]
    public class ProdThreePackDetailController : BaseController
    {
        /// <summary>
        /// 三级装箱明细接口
        /// </summary>
        private readonly IProdThreePackDetailService _ProdThreePackDetailService;

        public ProdThreePackDetailController(IProdThreePackDetailService ProdThreePackDetailService)
        {
            _ProdThreePackDetailService = ProdThreePackDetailService;
        }

        /// <summary>
        /// 查询三级装箱明细列表
        /// </summary>
        /// <param name="parm"></param>
        /// <returns></returns>
        [HttpGet("pageList")]
        [ActionPermissionFilter(Permission = "prod:threePackDetail:list")]
        public IActionResult PageProdThreePackDetail([FromQuery] ProdThreePackDetailQueryDto parm)
        {
            var response = _ProdThreePackDetailService.GetPageList(parm);
            return SUCCESS(response);
        }


        /// <summary>
        /// 查询三级装箱明细详情
        /// </summary>
        /// <param name="DetailId"></param>
        /// <returns></returns>
        [HttpGet("{DetailId}")]
        [ActionPermissionFilter(Permission = "prod:threePackDetail:query")]
        public IActionResult GetProdThreePackDetail(string DetailId)
        {
            var response = _ProdThreePackDetailService.GetInfo(DetailId);
            
            var info = response.Adapt<ProdThreePackDetailDto>();
            return SUCCESS(info);
        }

        /// <summary>
        /// 添加三级装箱明细
        /// </summary>
        /// <returns></returns>
        [HttpPost]
        [ActionPermissionFilter(Permission = "prod:threePackDetail:add")]
        [Log(Title = "三级装箱明细", BusinessType = BusinessType.INSERT)]
        public IActionResult AddProdThreePackDetail([FromBody] ProdThreePackDetailDto parm)
        {
            var modal = parm.Adapt<ProdThreePackDetail>().ToCreate(HttpContext);

            var response = _ProdThreePackDetailService.AddProdThreePackDetail(modal);

            return SUCCESS(response);
        }

        /// <summary>
        /// 更新三级装箱明细
        /// </summary>
        /// <returns></returns>
        [HttpPut]
        [ActionPermissionFilter(Permission = "prod:threePackDetail:edit")]
        [Log(Title = "三级装箱明细", BusinessType = BusinessType.UPDATE)]
        public IActionResult UpdateProdThreePackDetail([FromBody] ProdThreePackDetailDto parm)
        {
            var modal = parm.Adapt<ProdThreePackDetail>().ToUpdate(HttpContext);
            var response = _ProdThreePackDetailService.UpdateProdThreePackDetail(modal);

            return ToResponse(response);
        }

        /// <summary>
        /// 删除三级装箱明细
        /// </summary>
        /// <returns></returns>
        [HttpPost("delete")]
        [ActionPermissionFilter(Permission = "prod:threePackDetail:delete")]
        [Log(Title = "三级装箱明细", BusinessType = BusinessType.DELETE)]
        public IActionResult DeleteProdThreePackDetail([FromBody] string[] ids)
        {
            return ToResponse(_ProdThreePackDetailService.Delete(ids));
        }

    }
}